package com.kx.smartdevice.mapper;

import com.kx.smartdevice.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {

    List<User> findAllUsers(@Param("username") String username,@Param("status") int status);

    @Insert("insert into users(username,password,type,status) values(#{username},#{password},#{type},#{status})")
    void addUser(User user);

    int deleteUserByIds(@Param("ids") String[] ids);

    //根据 用户名查询 id 是否存在,主要判断用户有没有注册
    @Select("select id from users where username=#{username}")
    Long getUserIdByUserName(String username);

    @Update("update users set username=#{username},password=#{password},type=#{type},status=#{status} where id=#{id}")
    int updateUser(User user);
}
